<?php
class LoginApp extends CommonApp {
   
   //登陆
    public function indexAct(){
    	if($_POST){
    		if(My::arr2var($_POST,'username')=='')
    			$this->ajaxReturn(300,"用户名填写有误!");
    		if(My::arr2var($_POST,'password')=='')
    			$this->ajaxReturn(300,"密码填写有误!");
    		$password = md5(md5($_POST['password']));
            $number = $_POST['username'];
    		$result = DB('members')->field('id,username,number')->where("number='{$number}' AND password = '{$password}'")->cache()->find();
            if(!$result)
                $this->ajaxReturn(300,'用户名或者密码输入错误!');
            $_SESSION['member'] = $result;
            $this->ajaxReturn(200,'登陆成功！');
    	}else $this->display();
    }
    
    //退出登陆
    public function loginoutact(){
         //删除本系统的session
        unset($_SESSION['member']);
        redirect(Router::encodeUrl('index.php?app=Login'));
    }
}